package net.flyinggroup.kafka.service;

import lombok.extern.slf4j.Slf4j;
import net.flyinggroup.kafka.model.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
@Slf4j
public class Consumer {
    @KafkaListener(topics = "users", groupId = "group_id")
    public void consume(User message) throws IOException {
        log.info(String.format("#### -> Consumed message -> %s", message));
    }

//    @KafkaListener(id = "fooGroup", topics = "users")
//    public void listen(String message) throws IOException {
//        log.info("Received: " + message);
////        if (message.startsWith("foo")) {
////            throw new RuntimeException("failed");
////        }
//    }

    @KafkaListener(id = "dltGroup", topics = "users.DLT")
    public void dltListen(String in) {
        log.info("Received from DLT: " + in);
    }
}

